package com.gxwy.shenzhou;

public class ZhuanZhangRequest implements StringHandler{

	private HeaderRequest header =new HeaderRequest(false);
	private String jyyl;
	public static final int JYYL_LEN=2;
	public static final int JYYL_FLAG=2;
	private String zhdh;
	public static final int ZHDH_LEN=32;
	public static final int ZHDH_FLAG=2;
	private String mm;
	public static final int MM_LEN=16;
	public static final int MM_FLAG=2;
	private String jyje;
	public static final int JYJE_LEN=15;
	public static final int JYJE_FLAG=2;
	private String skrzh;
	public static final int SKRZH_LEN=32;
	public static final int SKRZH_FLAG=2;
	private String skrhh;
	public static final int SKRHH_LEN=12;
	public static final int SKRHH_FLAG=2;
	private String skhhm;
	public static final int SKHHM_LEN=50;
	public static final int SKHHM_FALG=2;
	private String skrmc;
	public static final int SKRMC_LEN=50;
	public static final int SKRMC_FLAG=2;
	private String yt;
	public static final int YT_LEN=60;
	public static final int YT_FLAG=2;
	private String zfjb;
	public static final int ZFJB_LEN=1;
	public static final int ZFJB_FLAG=2;
	private String ydbz;
	public static final int YDBZ_LEN=1;
	public static final int YDBZ_FLAG=2;
	private String dfdz;
	public static final int DFDZ_LEN=30;
	public static final int DFDZ_FLAG=2;
	private String skhmc;
	public static final int SKHMC_LEN=60;
	public static final int SKHMC_FLAG=2;
	public static final int TOTAL_LEN=JYYL_LEN+ZHDH_LEN+MM_LEN+JYJE_LEN+SKRZH_LEN+
			SKRHH_LEN+SKHHM_LEN+SKRMC_LEN+YT_LEN+ZFJB_LEN+YDBZ_LEN+DFDZ_LEN+SKHMC_LEN;
	private int reallen=0;
	public HeaderRequest getHeader() {
		return header;
	}

	public void setHeader(HeaderRequest header) {
		this.header = header;
	}

	public String getJyyl() {
		return jyyl;
	}

	public void setJyyl(String jyyl) throws Exception {
		if(jyyl==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(jyyl.getBytes("gbk").length<JYYL_LEN){
			this.jyyl=Supply.supply(jyyl,JYYL_FLAG, JYYL_LEN);
		}else if(jyyl.getBytes("gbk").length>JYYL_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.jyyl = jyyl;			
		}
	}

	public String getZhdh() {
		return zhdh;
	}

	public void setZhdh(String zhdh) throws Exception {
		if(zhdh==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(zhdh.getBytes("gbk").length<ZHDH_LEN){
			this.zhdh=Supply.supply(zhdh,ZHDH_FLAG, ZHDH_LEN);
		}else if(zhdh.getBytes("gbk").length>ZHDH_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.zhdh = zhdh;			
		}
	}

	public String getMm() {
		return mm;
	}

	public void setMm(String mm) throws Exception {
		if(mm==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(mm.getBytes("gbk").length<MM_LEN){
			this.mm=Supply.supply(mm,MM_FLAG, MM_LEN);
		}else if(mm.getBytes("gbk").length>MM_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.mm = mm;			
		}
	}

	public String getJyje() {
		return jyje;
	}

	public void setJyje(String jyje) throws Exception  {
		if(jyje==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(jyje.getBytes("gbk").length<JYJE_LEN){
			this.jyje=Supply.supply(jyje,JYJE_FLAG,JYJE_LEN);
		}else if(jyje.getBytes("gbk").length>JYJE_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.jyje = jyje;			
		}
	}

	public String getSkrzh() {
		return skrzh;
	}

	public void setSkrzh(String skrzh) throws Exception {
		if(skrzh==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(skrzh.getBytes("gbk").length<SKRZH_LEN){
			this.skrzh=Supply.supply(skrzh,SKRZH_FLAG,SKRZH_LEN);
		}else if(skrzh.getBytes("gbk").length>SKRZH_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.skrzh = skrzh;			
		}	
	}

	public String getSkrhh() {
		return skrhh;
	}

	public void setSkrhh(String skrhh) throws Exception {
		if(skrhh==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(skrhh.getBytes("gbk").length<SKRHH_LEN){
			this.skrhh=Supply.supply(skrhh,SKRHH_FLAG,SKRHH_LEN);
		}else if(skrhh.getBytes("gbk").length>SKRHH_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.skrhh = skrhh;			
		}
	}

	public String getSkhhm() {
		return skhhm;
	}

	public void setSkhhm(String skhhm) throws Exception {
		if(skhhm==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(skhhm.getBytes("gbk").length<SKHHM_LEN){
			this.skhhm=Supply.supply(skhhm,SKHHM_FALG,SKHHM_LEN);
		}else if(skhhm.getBytes("gbk").length>SKHHM_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.skhhm = skhhm;			
		}
	}

	public String getSkrmc() {
		return skrmc;
	}

	public void setSkrmc(String skrmc) throws Exception {
		if(skrmc==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(skrmc.getBytes("gbk").length<SKRMC_LEN){
			this.skrmc=Supply.supply(skrmc,SKRMC_FLAG,SKRMC_LEN);
		}else if(skrmc.getBytes("gbk").length>SKHHM_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.skrmc = skrmc;			
		}
	}

	public String getYt() {
		return yt;
	}

	public void setYt(String yt) throws Exception {
		if(yt==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(yt.getBytes("gbk").length<YT_LEN){
			this.yt=Supply.supply(yt,YT_FLAG,YT_LEN);
		}else if(yt.getBytes("gbk").length>YT_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.yt = yt;			
		}
	}

	public String getZfjb() {
		return zfjb;
	}

	public void setZfjb(String zfjb) throws Exception {
		if(zfjb==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(zfjb.getBytes("gbk").length<ZFJB_LEN){
			this.zfjb=Supply.supply(zfjb,ZFJB_FLAG,ZFJB_LEN);
		}else if(zfjb.getBytes("gbk").length>ZFJB_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.zfjb = zfjb;			
		}
	}

	public String getYdbz() {
		return ydbz;
	}

	public void setYdbz(String ydbz) throws Exception {
		if(ydbz==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(ydbz.getBytes("gbk").length<YDBZ_LEN){
			this.ydbz=Supply.supply(ydbz,YDBZ_FLAG,YDBZ_LEN);
		}else if(ydbz.getBytes("gbk").length>YDBZ_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.ydbz = ydbz;			
		}
	}

	public String getDfdz() {
		return dfdz;
	}

	public void setDfdz(String dfdz) throws Exception {
		if(dfdz==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(dfdz.getBytes("gbk").length<DFDZ_LEN){
			this.dfdz=Supply.supply(dfdz,DFDZ_FLAG,DFDZ_LEN);
		}else if(dfdz.getBytes("gbk").length>DFDZ_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.dfdz = dfdz;			
		}
	}

	public String getSkhmc() {
		return skhmc;
	}

	public void setSkhmc(String skhmc) throws Exception {
		if(skhmc==null){
			Exception e=new Exception("String is null");
			throw e;
		}else if(skhmc.getBytes("gbk").length<SKHMC_LEN){
			this.skhmc=Supply.supply(skhmc,SKHMC_FLAG,SKHMC_LEN);
		}else if(skhmc.getBytes("gbk").length>SKHMC_LEN){
			 Exception e=new Exception("Too long");
			 throw e;
		}else{
			this.skhmc = skhmc;			
		}
	}

	public String build() throws Exception {
		if(this.getHeader()==null){
			throw new Exception("Header is null");
		}
		if(this.getJyyl()==null){
			this.setJyyl("");
		}
		if(this.getZhdh()==null){
			this.setZhdh("");
		}
		if(this.getMm()==null){
			this.setMm("");
		}
		if(this.getJyje()==null){
			this.setJyje("");
		}
		if(this.getSkrzh()==null){
			this.setSkrzh("");
		}
		if(this.getSkrhh()==null){
			this.setSkrhh("");
		}
		if(this.getSkhhm()==null){
			this.setSkhhm("");
		}
		if(this.getSkrmc()==null){
			this.setSkrmc("");
		}
		if(this.getYt()==null){
			this.setYt("");;
		}
		if(this.getZfjb()==null){
			this.setZfjb("");
		}
		if(this.getYdbz()==null){
			this.setYdbz("");
		}
		if(this.getDfdz()==null){
			this.setDfdz("");
		}
		if(this.getSkhmc()==null){
			this.setSkhmc("");
		}
		Integer totallen=header.TOTAL_LEN+TOTAL_LEN-HeaderRequest.LEN_LEN;
		this.getHeader().setLen(totallen.toString());
		return this.getHeader().build()+this.getJyyl()+this.getZhdh()+this.getMm()+this.jyje+this.getSkrzh()+
				this.getSkrhh()+this.getSkhhm()+this.getSkrmc()+this.getYt()+this.getZfjb()+this.getYdbz()+this.getDfdz()+this.getSkhmc();
	}

	public void parse(String str) throws Exception {
		if(str==null){
			Exception e=new Exception("String is null");
			 throw e;
		}else if(str.getBytes("gbk").length<header.TOTAL_LEN+TOTAL_LEN){
			Exception e=new Exception("Invalid request");
			 throw e;
		}else{
			String headerLen=SplitString.splitString(str,reallen, reallen+header.TOTAL_LEN);
			reallen+=header.TOTAL_LEN;
			header.parse(headerLen);
			this.setJyyl(SplitString.splitString(str, reallen,reallen+JYYL_LEN));
			reallen+=JYYL_LEN;
			this.setZhdh(SplitString.splitString(str, reallen, reallen)+ZHDH_LEN);
			reallen+=ZHDH_LEN;
			this.setMm(SplitString.splitString(str, reallen, reallen+MM_LEN));
			reallen+=MM_LEN;
			this.setJyje(SplitString.splitString(str, reallen, reallen+JYJE_LEN));
			reallen+=JYJE_LEN;
			this.setSkrzh(SplitString.splitString(str, reallen, reallen+SKRZH_LEN));
			reallen+=SKRZH_LEN;
			this.setSkrhh(SplitString.splitString(str, reallen, reallen+SKRHH_LEN));
			reallen+=SKRHH_LEN;
			this.setSkhhm(SplitString.splitString(str, reallen, reallen+SKHHM_LEN));
			reallen+=SKHHM_LEN;
			this.setSkrmc(SplitString.splitString(str, reallen, reallen+SKRMC_LEN));
			reallen+=SKRMC_LEN;
			this.setYt(SplitString.splitString(str, reallen,reallen+YT_LEN));
			reallen+=YT_LEN;
			this.setZfjb(SplitString.splitString(str, reallen, reallen+ZFJB_LEN));
			reallen+=ZFJB_LEN;
			this.setYdbz(SplitString.splitString(str, reallen, reallen+YDBZ_LEN));
			reallen+=YDBZ_LEN;
			this.setDfdz(SplitString.splitString(str, reallen, reallen+DFDZ_LEN));
			reallen+=DFDZ_LEN;
			this.setSkhmc(SplitString.splitString(str, reallen, reallen+SKHMC_LEN));
			reallen+=SKHMC_LEN;
		}
	}
	
}
